use rbatis::sql::Page;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlatformPage<T> {
    /// data
    pub records: Vec<T>,
    /// total num
    pub total: u64,
    /// pages
    pub pages: u64,
    /// current page index
    pub page_no: u64,
    /// default 10
    pub page_size: u64,
    /// is search_count
    pub search_count: bool,
}

impl<T> PlatformPage<T> {
    pub fn new(page: Page<T>) -> Self {
        Self {
            records: page.records,
            total: page.total,
            pages: page.pages,
            page_no: page.page_no,
            page_size: page.page_size,
            search_count: page.search_count,
        }
    }
}
